home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gp_sysv.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  1.9 KB  |  69 lines

  1. /* Copyright (C) 1992 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gp_sysv.c,v 1.2 2000/09/19 19:00:25 lpd Exp $ */
  20. /* System V Unix-specific routines for Ghostscript */
  21.  
  22. /* This file contains a couple of standard Unix library procedures */
  23. /* that a few System V platforms don't provide. */
  24. /* Note that this file is NOT used for SVR4 platforms. */
  25. #include <errno.h>
  26. #include "stdio_.h"
  27. #include "time_.h"
  28. #include <sys/types.h>
  29. #include <sys/times.h>
  30. #include <sys/stat.h>
  31. #include <sys/param.h>
  32.  
  33. /* rename */
  34. int
  35. rename(const char *a, const char *b)
  36. {
  37.     if (access(a, 0) == -1)
  38.     return (-1);
  39.     unlink(b);
  40.     if (link(a, b) == -1)
  41.     return (-1);
  42.     if (unlink(a) == -1) {
  43.     unlink(b);        /* ??? */
  44.     return (-1);
  45.     }
  46.     return (0);
  47. }
  48.  
  49. /* gettimeofday */
  50. #ifndef HZ
  51. #  define    HZ    100    /* see sys/param.h */
  52. #endif
  53. int
  54. gettimeofday(struct timeval *tvp, struct timezone *tzp)
  55. {
  56.     struct tms tms;
  57.     static long offset = 0;
  58.     long ticks;
  59.  
  60.     if (!offset) {
  61.     time(&offset);
  62.     offset -= (times(&tms) / HZ);
  63.     }
  64.     ticks = times(&tms);
  65.     tvp->tv_sec = ticks / HZ + offset;
  66.     tvp->tv_usec = (ticks % HZ) * (1000 * 1000 / HZ);
  67.     return 0;
  68. }
  69.